package org.sky.wall.visual.util

import android.content.Context
import com.hjq.permissions.OnPermissionCallback
import com.hjq.permissions.Permission
import com.hjq.permissions.XXPermissions

/**
 *Create by Xianban
 *2024/1/16 10:06
 */

class PermissionUtil {
	companion object {
		fun initPermission(context: Context, callback: PermissionCallback?) {
			XXPermissions.with(context).permission(Permission.CAMERA)
				.request(object : OnPermissionCallback {
					override fun onGranted(permissions: MutableList<String>, status: Boolean
					) {
						if (!status) {
							return
						}
						callback?.onPermissionGranted()
					}
					
					override fun onDenied(permissions: MutableList<String>, not: Boolean
					) {
						if (not) {
							XXPermissions.startPermissionActivity(context, permissions)
						}
					}
				})
		}
	}
	interface PermissionCallback {
		fun onPermissionGranted()
	}
}